package cn.huixh.blindbox.pojo.bo;

import cn.huixh.blindbox.pojo.dto.FileDTO;
import cn.huixh.blindbox.pojo.po.Account;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author huixh
 * @version 1.0
 * @date 2022/5/10 10:41
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AccountFileBO {

    /**
     * 上传文件对象
     */
    private MultipartFile file;
    /**
     * 上传用户 id
     */
    private String accountId;

    private String md5;

    private String fileId;


    public static AccountFileBO of(FileDTO fileDTO, Account account, String md5) {
        return new AccountFileBO(fileDTO.getFile(), account.getId(), md5, "");
    }

    public static AccountFileBO of(FileDTO fileDTO, String accountId) {
        return new AccountFileBO(fileDTO.getFile(), accountId, fileDTO.getMd5(), "");
    }
}
